<?php echo module_open(); ?>
<tr class="no-border">
    <td>
        <input type="hidden" class="tabId" value="<?php echo $GLOBALS['var']['mytab'] ?>" />
        <ul id="myTab" class="nav nav-tabs">
            <li class="hide640<?php echo ($GLOBALS['var']['mytab'] == 0 ? ' active' : '') ?>" onclick="set_mytab($(this))"><a href="#tabs-0" data-toggle="tab">Hosting &amp; Domain</a></li>
            <li class="hide640<?php echo ($GLOBALS['var']['mytab'] == 1 ? ' active' : '') ?>" onclick="set_mytab($(this))"><a href="#tabs-1" data-toggle="tab">Công cụ</a></li>
            <li class="dropdown active show640">
                <a class="dropdown-toggle" data-toggle="dropdown" href="#"><span class="current-tab-name">Hosting &amp; Domain</span> <span class="caret"></span></a>
                <ul class="dropdown-menu">
                    <li <?php echo ($GLOBALS['var']['mytab'] == 0 ? ' class="active"' : '') ?>onclick="set_mytab($(this))"><a href="#tabs-0" data-toggle="tab">Hosting &amp; Domain</a></li>
                    <li <?php echo ($GLOBALS['var']['mytab'] == 1 ? ' class="active"' : '') ?>onclick="set_mytab($(this))"><a href="#tabs-1" data-toggle="tab">Công cụ</a></li>
                </ul>
            </li>
        </ul>
        <div id="myTabContent" class="tab-content">
            <div id="tabs-0" class="tab-pane<?php echo ($GLOBALS['var']['mytab'] == 0 ? ' active' : '') ?>">
                <table cellpadding="0" cellspacing="0" width="100%" border="0">
                    <tr>
                        <td class="fr">
                            <div id="visit_month_status" style="padding-right: 20px; height: auto !important">
                                <h2>Gói dịch vụ <?php echo HOSTING_PACKAGE ?></h2>
                                <div style="float: left; padding: 5px 0px;">Thời gian duy trì<?php echo($samDomainHost ? ' &amp; domain' : '') ?>: <strong><?PHP echo HOST_YEAR_REG ?></strong> năm<br /><strong style="font-size: 18px;"><?php echo strftime("%d/%m/%Y", strtotime(HOST_DATE_REG)) ?></strong></div>
                                <div style="float: right; padding: 5px 0px; text-align: right;">Thời điểm gia hạn<br /><strong style="font-size: 18px;"><?php echo strftime("%d/%m/%Y", $expireHost) ?></strong></div>
                                <div style="clear: both;"></div>
                                <div class="slider sliderMin-7 sliderLightOrange ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all" aria-disabled="true" style="height: 14px;"><div class="ui-slider-range ui-widget-header ui-slider-range-min" style="width: <?php echo $pDayHostUsed ?>%; height: 14px;"></div></div>
                                <div class="field_notice">Hosting<?php echo($samDomainHost ? ' &amp; domain' : '') ?> đã hoạt động: <span class="must sliderMin-7"><?php echo round($dayHostUsed) ?> ngày</span></div>
                                <div class="alerts" style="padding-top: 5px;">
                                    <?php
                                    if ($dayHostLeft < 1)
                                    {
                                    ?>
                                    <div class="alert alert-error">
                                        <button type="button" class="close" data-dismiss="alert">×</button>
                                        <strong>Chú ý!</strong> Hosting<?php echo($samDomainHost ? ' &amp; domain' : '') ?> của bạn đã hết hạn sử dụng. Vui lòng gia hạn dịch vụ.
                                    </div>
                                    <?php
                                    }
                                    else if ($dayHostLeft < 15)
                                    {
                                    ?>
                                    <div class="alert alert-block">
                                        <button type="button" class="close" data-dismiss="alert">×</button>
                                        <strong>Chú ý!</strong> Thời hạn sử dụng dịch vụ hosting<?php echo($samDomainHost ? ' &amp; domain' : '') ?> của bạn chỉ còn <?php echo $dayHostLeft ?> ngày. Vui lòng gia hạn dịch vụ.
                                    </div>
                                    <?php
                                    }
                                    else if ($dayHostLeft < 30)
                                    {
                                    ?>
                                    <div class="alert alert-info">
                                        <button type="button" class="close" data-dismiss="alert">×</button>
                                        <strong>Chú ý!</strong> Thời hạn sử dụng dịch vụ hosting<?php echo($samDomainHost ? ' &amp; domain' : '') ?> của bạn chỉ còn <?php echo $dayHostLeft ?> ngày. Vui lòng gia hạn dịch vụ.
                                    </div>
                                    <?php
                                    }
                                    ?>
                                </div>
                                <?php
                                if (!$samDomainHost)
                                {
                                ?>
                                <hr style="margin-top: 20px;" />
                                <div style="float: left; padding: 5px 0px;">Kích hoạt domain: <strong><?PHP echo DOMAIN_YEAR_REG ?></strong> năm<br /><strong style="font-size: 18px;"><?php echo strftime("%d/%m/%Y", strtotime(DOMAIN_DATE_REG)) ?></strong></div>
                                <div style="float: right; padding: 5px 0px; text-align: right;">Thời điểm gia hạn<br /><strong style="font-size: 18px;"><?php echo strftime("%d/%m/%Y", $expireDomain) ?></strong></div>
                                <div style="clear: both;"></div>
                                <div class="slider sliderMin-2 sliderGreen ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all" aria-disabled="true" style="height: 14px;"><div class="ui-slider-range ui-widget-header ui-slider-range-min" style="width: <?php echo $pDayDomainUsed ?>%; height: 14px;"></div></div>
                                <div class="field_notice">Domain đã hoạt động: <span class="must sliderMin-2"><?php echo round($dayDomainUsed) ?> ngày</span></div>
                                <div class="alerts" style="padding-top: 5px;">
                                    <?php
                                    if ($dayDomainLeft < 15)
                                    {
                                    ?>
                                    <div class="alert alert-block">
                                        <button type="button" class="close" data-dismiss="alert">×</button>
                                        <strong>Chú ý!</strong> Thời hạn sử dụng dịch vụ domain của bạn chỉ còn <?php echo $dayDomainLeft ?> ngày. Vui lòng gia hạn dịch vụ.
                                    </div>
                                    <?php
                                    }
                                    else if ($dayDomainLeft < 30)
                                    {
                                    ?>
                                    <div class="alert alert-info">
                                        <button type="button" class="close" data-dismiss="alert">×</button>
                                        <strong>Chú ý!</strong> Thời hạn sử dụng dịch vụ domain của bạn chỉ còn <?php echo $dayDomainLeft ?> ngày. Vui lòng gia hạn dịch vụ.
                                    </div>
                                    <?php
                                    }
                                    ?>
                                </div>
                                <?php
                                }
                                ?>
                                <div class="alerts">
                                    <?php
                                    if ($left < 20 * 1024 * 1024)
                                    {
                                    ?>
                                    <div class="alert alert-error">
                                        <button type="button" class="close" data-dismiss="alert">×</button>
                                        <strong>Chú ý!</strong> Dung lượng lưu trữ hosting của bạn chỉ còn <?php echo format_size($left) ?>.
                                    </div>
                                    <?php
                                    }
                                    else if ($left < 50 * 1024 * 1024)
                                    {
                                    ?>
                                    <div class="alert alert-block">
                                        <button type="button" class="close" data-dismiss="alert">×</button>
                                        <strong>Chú ý!</strong> Dung lượng lưu trữ hosting của bạn chỉ còn <?php echo format_size($left) ?>.
                                    </div>
                                    <?php
                                    }
                                    ?>
                                </div>
                            </div>
                            <div id="visit_month">
                                <div id="chartHostingStatus" style="margin: 0px 0px; height: 420px !important">&nbsp;</div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="head">Database server</td>
                    </tr>
                    <tr>
                        <td class="fr" valign="top">
                            <div style="clear: both; line-height: 1.6em;">
                                <div style="display: inline-block; width: 100px;">Server</div>
                                <div style="display: inline-block; min-width: 200px;">: <?php echo $database_server['server_info'] ?></div>
                            </div>
                            <div style="clear: both; line-height: 1.6em;">
                                <div style="display: inline-block; width: 100px;">Server type</div>
                                <div style="display: inline-block; min-width: 200px;">: <?php echo strtoupper($database_server['server_type']) ?></div>
                            </div>
                            <div style="clear: both; line-height: 1.6em;">
                                <div style="display: inline-block; width: 100px;">Server version</div>
                                <div style="display: inline-block; min-width: 200px;">: <?php echo $database_server['server_version'] ?></div>
                            </div>
                            <div style="clear: both; line-height: 1.6em;">
                                <div style="display: inline-block; width: 100px;">Protocol version</div>
                                <div style="display: inline-block; min-width: 200px;">: <?php echo $database_server['proto_info'] ?></div>
                            </div>
                            <div style="clear: both; line-height: 1.6em;">
                                <div style="display: inline-block; width: 100px;">User</div>
                                <div style="display: inline-block; min-width: 200px;">: <?php echo $database_server['server_user'] ?></div></div>
                            <div style="clear: both; line-height: 1.6em;">
                                <div style="display: inline-block; width: 100px;">Server charset</div>
                                <div style="display: inline-block; min-width: 200px;">: <?php echo $database_server['server_charset'] ?></div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="head">Web server</td>
                    </tr>
                    <tr>
                        <td class="fr" valign="top">
                            <div style="clear: both; line-height: 1.6em;">
                                <div style="display: inline-block; width: 100px;">Server name</div>
                                <div style="display: inline-block; min-width: 200px;">: <?php echo $web_server['server_name'] ?></div>
                            </div>
                            <div style="clear: both; line-height: 1.6em;">
                                <div style="display: inline-block; width: 100px;">Server address</div>
                                <div style="display: inline-block; min-width: 200px;">: <?php echo $web_server['server_addr'] ?></div>
                            </div>
                            <div style="clear: both; line-height: 1.6em;">
                                <div style="display: inline-block; width: 100px;">HTTPS protocol</div>
                                <div style="display: inline-block; min-width: 200px;">: <?php echo $web_server['https'] ?></div>
                            </div>
                            <div style="clear: both; line-height: 1.6em;">
                                <div style="display: inline-block; width: 100px;">Server Software</div>
                                <div style="display: inline-block; min-width: 200px;">: <?php echo $web_server['server_software'] ?></div>
                            </div>
                            <div style="clear: both; line-height: 1.6em;">
                                <div style="display: inline-block; width: 100px;">Server Protocol</div>
                                <div style="display: inline-block; min-width: 200px;">: <?php echo $web_server['server_protocol'] ?></div>
                            </div>
                            <div style="clear: both; line-height: 1.6em;">
                                <div style="display: inline-block; width: 100px;">Document root</div>
                                <div style="display: inline-block; min-width: 200px;">: <?php echo $web_server['document_root'] ?></div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="head">User client</td>
                    </tr>
                    <tr>
                        <td class="fr" valign="top">
                            <div style="clear: both; line-height: 1.6em;">
                                <div style="display: inline-block; width: 100px;">User agent</div><div style="display: inline-block;">: <?php echo $user_client['user_agent'] ?></div></div>
                            <div style="clear: both; line-height: 1.6em;">
                                <div style="display: inline-block; width: 100px;">IP address</div><div style="display: inline-block;">: <?php echo $user_client['ip'] ?></div></div>
                        </td>
                    </tr>
                </table>
            </div>
            <div id="tabs-1" class="tab-pane<?php echo ($GLOBALS['var']['mytab'] == 1 ? ' active' : '') ?>">
                <table cellpadding="0" cellspacing="0" width="100%" border="0">
                    <tr>
                        <td class="fr" colspan="9">
                            <div style="float: left; margin-right: 20px;">
                                <div class="submitBtn btn btn-success util_table" data-op="check"><i class="icon glyphicons white transfer"></i><span class="hide480">Kiểm tra</span></div>
                                <div class="submitBtn btn btn-info util_table" data-op="analyze"><i class="icon glyphicons white screenshot"></i><span class="hide480">Phân tích</span></div>
                                <div class="submitBtn btn btn-danger util_table" data-op="repair"><i class="icon glyphicons white cogwheels"></i><span class="hide480">Sữa chữa</span></div>
                                <div class="submitBtn btn btn-warning util_table" data-op="optimize"><i class="icon glyphicons white magic"></i><span class="hide480">Tối ưu</span></div>
                            </div>
                            <div class="status_mes check repair" style="float: left; display: none; line-height: 32px">
                                <div class="progress progress-danger" style="float: left; height: 25px !important; width: 250px !important; margin-top: 2px; margin-right: 10px; margin-bottom: 0px;"><div class="progress-bar" style="width: 0%;"></div></div>
                                <div style="float: left;">Tình trạng bảng dữ liệu <span style="font-weight: bold;"></span> tốt!</div>
                            </div>
                            <div class="status_mes optimize" style="float: left; display: none; line-height: 32px">
                                <div class="progress progress-success" style="float: left; height: 25px !important; width: 250px !important; margin-top: 2px; margin-right: 10px; margin-bottom: 0px"><div class="progress-bar" style="width: 0%;"></div></div>
                                <div style="float: left;">Tối ưu truy cập bảng dữ liệu <span style="font-weight: bold;"></span> hoàn tất!</div>
                            </div>
                            <div class="status_mes analyze" style="float: left; display: none; line-height: 32px">
                                <div class="progress progress-info" style="float: left; height: 25px !important; width: 250px !important; margin-top: 2px; margin-right: 10px; margin-bottom: 0px"><div class="progress-bar" style="width: 0%;"></div></div>
                                <div style="float: left;">Bảng dữ liệu <span style="font-weight: bold;"></span> sẵn sàng để cập nhập!</div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="head center" width="2%">#</td>
                        <td class="head" width="12%">Bảng</td>
                        <td class="head hide768" width="10%">Kiểu dữ liệu</td>
                        <td class="head hide640" width="10%">Kiểu mã hóa</td>
                        <td class="head right hide480" width="5%">Số hàng dữ liệu</td>
                        <td class="head right hide640" width="5%">Trung bình một hàng</td>
                        <td class="head right" width="6%">Kích thước bảng</td>
                        <td class="head hide768" width="10%">Cập nhập lần cuối</td>
                    </tr>
                    <?php
                    if(count($tables) && is_array($tables))
                    {
                        $i = 1;
                        foreach ($tables as $row)
                        {
                    ?>
                    <tr class="highlight" name="<?php echo $row['Name'] ?>">
                        <td class="fr center"><?php echo stt($i, $i++) ?></td>
                        <td class="fr">
                            <?php echo $row['Name'] ?>
                            <div class="status icon glyphicons ok_2" style="display: none; float: right;"></div>
                            <div class="status icon glyphicons circle_exclamation_mark" style="display: none; float: right;"></div>
                        </td>
                        <td class="fr hide768"><?php echo $row['Engine'] ?></td>
                        <td class="fr hide640"><?php echo $row['Collation'] ?></td>
                        <td class="fr right hide480"><?php echo number_format($row['Rows']) ?></td>
                        <td class="fr right hide640"><?php echo format_size($row['Avg_row_length']) ?></td>
                        <td class="fr right"><?php echo format_size($row['Data_length'] + $row['Index_length']) ?></td>
                        <td class="fr hide768"><?php echo strftime(TIME_STR, strtotime($row['Update_time'])) ?></td>
                    </tr>
                    <?php
                        }
                    }
                    else
                    {
                        echo no_data_mes(8);
                    }
                    ?>
                </table>
            </div>
        </div>
    </td>
</tr>
<?php echo module_close(); ?>
<script>
$(function () {
    $('#chartHostingStatus').highcharts({
        chart: {
            plotBackgroundColor: null,
            plotBorderWidth: null,
            plotShadow: false,
            borderRadius: 0,
            backgroundColor:'transparent'
        },
        title: {
            text: 'Dung lượng Hosting <?php echo DISK_QUOTA ?>MB'
        },
        tooltip: {
            pointFormat: '<b>{point.percentage:.1f}%</b>'
        },
        plotOptions: {
            pie: {
                allowPointSelect: true,
                cursor: 'pointer',
                dataLabels: {
                    enabled: true,
                    format: '<b>{point.name}</b>: {point.percentage:.1f} %'
                }
            }
        },
        series: [{
            type: 'pie',
            name: 'dung lượng',
            data: [
                ['Source web <?php echo format_size(SOURCE_SIZE) ?>', <?php echo $pCodeSize ?>],
                ['Database <?php echo format_size($sqlUsage) ?>', <?php echo $pSqlUsage ?>],
                ['Upload file <?php echo format_size($upload_file) ?>', <?php echo $pUpload_file ?>],
                ['Email folder <?php echo format_size($emailSize) ?>', <?php echo $pEmailSize ?>],
                ['Còn lại <?php echo format_size($left) ?>', <?php echo $pLeft ?>]
            ]
        }],
        credits: {
            enabled: false
        }
    });
});
</script>
<script src="js/highcharts/highcharts.js"></script>
<script src="js/highcharts/modules/exporting.js"></script>